package com.app.controller;

import com.app.model.AdvertisementModel;
import com.app.model.AdvertisementSonModel;
import com.app.service.*;
import com.app.util.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Description:首页图集
 * @Author: N
 * @Date: 2022/10/29 15:26
 */
@RestController
@RequestMapping("/")
public class AdvertisementController {
    @Autowired
    AdvertisementService advertisementService;
    @Autowired
    AdvertisementSonService advertisementSonService;

    @RequestMapping(value = "/getAdvertisementList", method = RequestMethod.GET)
    public Result<Object> getAttentionList(Integer userType,Integer seat){
        List<AdvertisementModel> advertisementModelList = advertisementService.getListByType(userType,seat);
        if(advertisementModelList!=null)
        {
            for (int i = 0; i < advertisementModelList.size(); i++) {
                List<AdvertisementSonModel> advertisementSonModelList = advertisementSonService.getListByFatherId(advertisementModelList.get(i).getId());
                advertisementModelList.get(i).setSonModelList(advertisementSonModelList);
            }
        }
        return Result.success(advertisementModelList);
    }

}
